<template>
  <el-card class="mb-2 card-sm">
    <div slot="header" class="d-flex justify-content-between">
      <h4>{{ title }}</h4>
      <el-switch v-model="visibleOfSearchPanel" :inactive-text="visibleOfSearchPanel ? '高级搜索' : '精简搜索'">
      </el-switch>
    </div>
    <el-form v-show="!visibleOfSearchPanel" :inline="true" :model="dataOfSearch" class="search-simple" size="mini">
      <el-form-item label="关键词">
        <el-input v-model="dataOfSearch.keyword" :placeholder="placeholder"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" :loading="loadingOfSearch" @click="onSearch()">模糊查询</el-button>
      </el-form-item>
    </el-form>
    <div v-show="visibleOfSearchPanel">
      <slot name="default">
        <el-form :inline="true" :model="dataOfSearch" size="mini">
          <el-form-item label="活动区域">
            <el-select v-model="dataOfSearch.region" placeholder="请选择活动区域">
              <el-option label="区域一" value="shanghai"></el-option>
              <el-option label="区域二" value="beijing"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="活动时间">
            <el-date-picker v-model="dataOfSearch.date" type="datetime" placeholder="选择日期时间">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="活动时间">
            <el-date-picker v-model="dataOfSearch.dateRange" type="datetimerange" range-separator="至"
              start-placeholder="开始日期" end-placeholder="结束日期">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="即时配送">
            <el-switch v-model="dataOfSearch.delivery"></el-switch>
          </el-form-item>
          <el-form-item label="活动性质">
            <el-checkbox-group v-model="dataOfSearch.type">
              <el-checkbox label="美食/餐厅线上活动" name="type"></el-checkbox>
              <el-checkbox label="地推活动" name="type"></el-checkbox>
              <el-checkbox label="线下主题活动" name="type"></el-checkbox>
              <el-checkbox label="单纯品牌曝光" name="type"></el-checkbox>
            </el-checkbox-group>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" :loading="loadingOfSearch" @click="onSearch()">查询</el-button>
          </el-form-item>
        </el-form>
      </slot>
    </div>
  </el-card>
</template>

<script>
/**
 * 数据表搜索面板组件
 */
export default {
  name: 'TableSearchPanel',
  props: {
    title: {
      type: String,
      default: '页面标题'
    },
    placeholder:{
      type:String,
      default:'ID/名称',
    },
  },
  data() {
    return {
      visibleOfSearchPanel: false,
      loadingOfSearch: false,
      // 查询数据
      dataOfSearch: {
        keyword: "",
        name: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
      },

    }
  },
  methods: {

  }
}
</script>
